import sys

from PySide2.QtCore import QFile
from PySide2.QtUiTools import QUiLoader
from PySide2.QtWidgets import QApplication

from ElementInteraction.share import main_share
from util.canvas import CTkPrScrn


class initialize:
    # 初始化
    def __init__(self):
        ui = main_share.SI.main
    #     检查元素按钮事件绑定
        ui.find_element_button.clicked.connect(lambda: self.mouse_monitor())

#     监听鼠标事件
    def mouse_monitor(self):
        prScrn = CTkPrScrn()

if __name__ == '__main__':
    app = QApplication([])

    qfile_stats = QFile("./static/ui/main.ui");
    qfile_stats.open(QFile.ReadOnly);
    qfile_stats.close();
    # 从UI定义中 创建一个相应的窗口对象
    # 里面的控件对象也成为了对象的属性
    qui = QUiLoader().load(qfile_stats);

    main_share.SI.main = qui;

    qui.setFixedSize(qui.width(), qui.height());

    qui.setWindowTitle("元素选择器");

    qui.show();

    initialize()

    app.exec_();